package com.wy.controller;

import com.wy.Service.DengjService;
import com.wy.pojo.Dengj;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/dengj")
@CrossOrigin
public class DengjController {
    @Resource
    private DengjService dengjService;

    String msg;
    @GetMapping("/list")
    public List<Dengj>seach(Integer huzuid){
        return dengjService.searchidAll(huzuid);
    }

    @GetMapping("/delete")
    public String delete(Integer id){
        try{
            dengjService.del(id);
            msg="删除成功";
        }catch (Exception e){
            msg="删除失败";
        }
        return msg;
    }

    @GetMapping("/add")
    public String add(Dengj dengj){
        try{
            dengjService.add(dengj);
            msg="添加成功";
        }catch (Exception e){
            msg="添加失败";
        }
        return msg;
    }
}
